package cn.getech.data.metadata.controller.change;


import cn.getech.data.intelligence.common.utils.BaseRes;
import cn.getech.data.intelligence.common.utils.DataRes;
import cn.getech.data.intelligence.common.utils.PageRes;
import cn.getech.data.metadata.entity.CollectionNotificationUser;
import cn.getech.data.metadata.entity.meta.CollectionTableInfo;
import cn.getech.data.metadata.model.req.change.CollectionNotificationUserReq;
import cn.getech.data.metadata.model.res.CollectionNotificationUserListRes;
import cn.getech.data.metadata.service.CollectionNotificationUserGroupService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(value="通知用户组管理",tags={"通知用户组管理"})
@RestController
@RequestMapping("md/notificationUser")
public class NotificationUserController {

    @Resource
    CollectionNotificationUserGroupService CollectionNotificationServiceImpl;

    @ApiOperation("通知用户组管理--带条件查询")
    @PostMapping("/list")
    public PageRes<IPage<CollectionNotificationUserListRes>> list(@RequestBody CollectionNotificationUserReq req){
        return BaseRes.okWithPage(CollectionNotificationServiceImpl.listBy(req));
    }


    @ApiOperation("一直id查询信息")
    @GetMapping("/info/{id}")
    public BaseRes info(@PathVariable("id") Long id){
        if(id!=null){
            CollectionNotificationUser byId = CollectionNotificationServiceImpl.getCollectionNotificationUserByid(id);
            return BaseRes.okWithData(byId);
        }
        return BaseRes.error("查询id不能为空");
    }

    @ApiOperation("通知用户组管理--新增")
    @PostMapping("/add")
    public BaseRes add(@RequestBody CollectionNotificationUser req){
        CollectionNotificationServiceImpl.add(req);
        return DataRes.ok();
    }


    @ApiOperation("通知用户组管理--修改")
    @PostMapping("/update")
    public BaseRes update(@RequestBody CollectionNotificationUser req){
        CollectionNotificationServiceImpl.upd(req);
        return DataRes.ok();
    }


    @ApiOperation("通知用户组管理--删除")
    @GetMapping("/delete")
    public BaseRes delete(@RequestParam("id") Long id){
        CollectionNotificationServiceImpl.del(id);
        return DataRes.ok();
    }
}
